//
//  MineStyle0Cell.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/9.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit
import SwiftyJSON

class MineStyle0Cell: UITableViewCell {
    
    var hb_Label:UILabel = UILabel.init()
    var cz_button:UIButton = UIButton.init()
    var fd_label:UILabel = UILabel.init()
    var dh_button:UIButton = UIButton.init()
    var fg_label:UILabel = UILabel.init()
    var sepLabel:UILabel = UILabel.init()
    
    var jsonData:JSON?{
        didSet{
        self.hb_Label.text = (jsonData?["balance"].stringValue ?? "") + "徽币"
        self.fd_label.text = (jsonData?["points"].stringValue ?? "") + "福豆"
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        self.hb_Label.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.width.equalTo(k_Wide/4)
            make.top.equalTo((45-14)/2)
            make.height.equalTo(14)
        }
        self.cz_button.snp.makeConstraints { (make) in
            make.left.equalTo((k_Wide/4)+((k_Wide/4 - 50)/2))
            make.top.equalTo((45-20)/2)
            make.height.equalTo(20)
            make.right.equalTo(-(k_Wide/4 - 50)/2 - (k_Wide/2))
        }
        self.fg_label.snp.makeConstraints { (make) in
            make.left.equalTo(k_Wide/2)
            make.size.equalTo(CGSize.init(width: 0.5, height: 45))
            make.top.equalTo(0)
        }
        self.fd_label.snp.makeConstraints { (make) in
            make.left.equalTo(k_Wide/2)
             make.width.equalTo(k_Wide/4)
            make.top.equalTo((45-14)/2)
            make.height.equalTo(14)
        }
        self.dh_button.snp.makeConstraints { (make) in
            make.left.equalTo((k_Wide/4)+((k_Wide/4 - 50)/2)+(k_Wide/2))
            make.top.equalTo((45-20)/2)
            make.height.equalTo(20)
            make.right.equalTo(-(k_Wide/4 - 50)/2)
        }
        self.sepLabel.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.bottom.equalTo(0)
            make.height.equalTo(0.5)
        }
    }
}
extension MineStyle0Cell{
    //MARK:configUI
    func setUI(){
       self.contentView.addSubview(self.hb_Label)
        self.contentView.addSubview(self.cz_button)
        self.contentView.addSubview(self.fg_label)
        self.contentView.addSubview(self.fd_label)
        self.contentView.addSubview(self.dh_button)
        self.contentView.addSubview(self.sepLabel)
        self.fg_label.backgroundColor = UIColor.lightGray
        self.hb_Label.text = "0徽币"
        self.hb_Label.textAlignment = .center
        self.hb_Label.font = UIFont.systemFont(ofSize: 14)
        self.cz_button.layer.cornerRadius = 5.0
        self.cz_button.layer.borderColor = UIColor.red.cgColor
        self.cz_button.layer.borderWidth = 1.0
        self.cz_button.backgroundColor = .red
        self.cz_button.titleLabel?.textColor = .white
        self.cz_button.setTitle("充值", for: .normal)
        self.cz_button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        self.fd_label.font = UIFont.systemFont(ofSize: 14)
        self.fd_label.text = "0福豆"
        self.fd_label.textAlignment = .center
        self.dh_button.layer.cornerRadius = 5.0
        self.dh_button.layer.borderWidth = 1.0
        self.dh_button.layer.borderColor = UIColor.red.cgColor
        self.dh_button.backgroundColor = .red
        self.dh_button.titleLabel?.textColor = .white
        self.dh_button.setTitle("兑换", for: .normal)
        self.dh_button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        self.sepLabel.backgroundColor = .lightGray
    }
}
